<?php
namespace tjsd\core;

use \tjsd\exceptions\UndefinedFunctionException;
use \tjsd\exceptions\UndefinedPropertyException;

/**
 * Prototype to all classes representing any object. Ensures strict interface.
 * 
 * Class blocks access to undefined methods and properties.
 * 
 * @author Jakub Tesárek <info@tjsd.cz>
 * @copyright 2012
 * @version 1.0
 */
abstract class Object {
	
	/**
	 * Called when a static method is called on class.
	 * 
	 * 
	 * @throws \tjsd\exceptions\UndefinedFunctionException
	 * @param string $method
	 * @param array $args
	 */
	public static function __callStatic($method, array $args) {
		throw new UndefinedFunctionException('Calling to undefined static method: ' . $method);
	}
	
	/**
	 * Called when method is called on object.
	 * 
	 * @throws \tjsd\exceptions\UndefinedFunctionException
	 * @param string $method
	 * @param string $args
	 */
	public function __call($method, $args) {
		throw new UndefinedFunctionException('Calling to undefined method: ' . $method);
	}
	
	/**
	 * Called when trying to get property.
	 * 
	 * @throws \tjsd\exceptions\UndefinedFunctionException
	 * @param string $name
	 */
	public function __get($name) {
		throw new UndefinedPropertyException('Cannot access undefined property: ' . $name);
	}
	
	/**
	 * Called when trying to set property.
	 * 
	 * @throws \tjsd\exceptions\UndefinedFunctionException
	 * @param string $name
	 * @param mixed $value
	 */
	public function __set($name, $value) {
		throw new UndefinedPropertyException('Cannot access undefined property: ' . $name);
	}
	
	/**
	 * Called when calling isset() on property.
	 * 
	 * @throws \tjsd\exceptions\UndefinedFunctionException
	 * @param string $name
	 */
	public function __isset($name) {
		return FALSE;
	}
}